package com.chen.controller;


import com.chen.dto.AllProductDto;
import com.chen.entity.Product;
import com.chen.mapper.ProductMapper;
import com.chen.service.ProductService;
import com.chen.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 商品信息表 前端控制器
 * </p>
 *
 * @author cws
 * @since 2024-11-22
 */
@RestController
@RequestMapping("/mall/product")
@Api(tags = "商品管理")
public class ProductController {

    @Resource
    ProductService productService;

    @ApiOperation("我们的产品")
    @GetMapping("/myProducts")
    public Result myProducts(@RequestParam("type") String type) {
        return Result.success(productService.myProducts(type));
    }


    @ApiOperation("所有商品")
    @PostMapping("/allProduct")
    public Result allProduct(@RequestBody AllProductDto allProductDto) {
        return productService.allProduct(allProductDto);
    }


    @ApiOperation("根据id查询商品详情")
    @GetMapping(value = "/detail/{id}",produces = "application/json;charset=UTF-8")
    public Result detail(@PathVariable Long id) {
        return Result.success(productService.detail(id));
    }


}

